package org.vectrics.recruiter.struts.admin.person;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.vectrics.struts.Request;
import org.vectrics.struts.VectricsActionForm;

/**
 * @author pgoette
 * Clase encargada de representar el formulario con los datos del Career
 */
public class CareerForm extends VectricsActionForm {
	
	private static final long serialVersionUID = 8395037678579661885L;

	/**
	 * id de career
	 */
	private String id;
	
	/**
	 * Descripcion de la career
	 */
	private String career;

	
	/**
	 * @return the id
	 */
	public String getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * @return the career
	 */
	public String getCareer() {
		return career;
	}

	/**
	 * @param career the career to set
	 */
	public void setCareer(String career) {
		this.career = career;
	}
	
	@Override
	protected ActionErrors doValidate(ActionMapping mapping, Request request) {
		
		ActionErrors errors = super.doValidate(mapping, request);
		
		if (this.wasButtonPressed(request, "cancel")) {
			return errors;
		}
		
		if ((this.getCareer()==null) || (this.getCareer().trim().equals(""))) {
			errors.add("career", new ActionMessage("error.requiered.career"));
		}
		
		return errors;
	}
	
}
